﻿<template>
	<div >
		<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
					<el-form :model="queryParams" ref="queryForm" :inline="true">
						<el-row :gutter="35">
						
			              <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" >
			              <el-form-item label="设备编码">
			              <el-input v-model="queryParams.num" clearable placeholder="设备编码"/>
			              </el-form-item>
			              </el-col>
						
                
			          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20 search-actions">
         
			          <div>
			          <el-button icon="ele-Refresh" @click="() => queryParams = {}"> 重置 </el-button>
			          <el-button type="primary" plain icon="ele-Search" @click="handleQuery" v-auth="'unitSc:page'"> 查询 </el-button>
			          </div>
			          </el-col>
			      </el-row>
			      </el-form>
	   </el-card>
		<el-card shadow="hover" style="margin-top: 8px">
			<el-table
				:data="tableData"
				style="width: 100%"
				v-loading="loading"
				tooltip-effect="light"
				row-key="id"
				border="">
				<el-table-column type="index" label="序号" width="55" align="center" fixed="" />
				
				 <el-table-column prop="num" label="设备编码" width="85" show-overflow-tooltip="" />

				 <el-table-column  label="叉使用" width="70" show-overflow-tooltip="" >
					<template #default="scope">				   
			
							<span tooltip="">{{ scope.row.usePoke==2?'右':scope.row.usePoke==3?'双':scope.row.usePoke==1?'左':'单' }} </span>  
                      				
			       </template>
				 </el-table-column>

				 <el-table-column  label="设备状态" width="170" show-overflow-tooltip="" >
					<template #default="scope">

						<el-tooltip v-if="scope.row.unitNum==1"  content="火灾 | 0 | 返送结束 | 作业ready | 动作 | 0 | 模式 | 电源" placement="top" effect="light">
							<span tooltip="">{{ scope.row.fire }} | 0 | {{scope.row.sendEnd}} | {{ scope.row.ready }} | {{ scope.row.action }} | 0 | {{ scope.row.mode }} | {{ scope.row.power }}</span>  
                       </el-tooltip>
					   
					   <el-tooltip v-if="scope.row.unitNum==2"  content="返送结束(右) | 返送结束(左) | 作业ready | 动作 | 0 | 0 | 模式 | 电源" placement="top" effect="light">
							<span tooltip="">{{ scope.row.sendEnd2 }} | {{scope.row.sendEnd}} | {{scope.row.ready}} | {{ scope.row.action }} | 0 | 0 | {{ scope.row.mode }} | {{ scope.row.power }}</span>  
                       </el-tooltip>				
			       </template>
				 </el-table-column>




				 <el-table-column  label="叉状态" width="170" show-overflow-tooltip="" >
					<template #default="scope">
						<el-tooltip v-if="scope.row.unitNum==1" content="0 | 0 | 0 | 单叉可用 | 0 | 0 | 0 | 托盘存在" placement="top" effect="light">
							<span tooltip="">0 | 0 | 0 | {{ scope.row.canPoke }} | 0 | 0 | 0 | {{ scope.row.existTray }}</span>  
                       </el-tooltip>

					   <el-tooltip v-if="scope.row.unitNum==2" content="火灾 | 右叉可用 | 左叉可用 | 0 | 0 | 0 | 右托盘存在 | 左托盘存在" placement="top" effect="light">
							<span tooltip="">{{ scope.row.fire }} | {{ scope.row.canPoke2 }} | {{ scope.row.canPoke }} | 0 | 0 | 0 | {{ scope.row.existTray2 }} | {{ scope.row.existTray }}</span>  
                       </el-tooltip>
					    
			       </template>
				 </el-table-column>

		
			
		  <el-table-column  label="取货位置" width="100" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.fromX }}-{{ scope.row.fromY }}-{{ scope.row.fromZ }}
			</template>
		  </el-table-column>

		  <el-table-column  label="放货位置" width="100" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.toX }}-{{ scope.row.toY }}-{{ scope.row.toZ }}
			</template>
		  </el-table-column>

		  <el-table-column  label="货物" width="190" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.tray }}-{{ scope.row.tray2 }}
			</template>
		  </el-table-column>

		  	
		  <el-table-column  label="右取货位置" width="100" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.fromX2 }}-{{ scope.row.fromY2 }}-{{ scope.row.fromZ2 }}
			</template>
		  </el-table-column>

		  <el-table-column  label="右放货位置" width="100" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.toX2 }}-{{ scope.row.toY2 }}-{{ scope.row.toZ2 }}
			</template>
		  </el-table-column>

		  <el-table-column  label="右货物" width="190" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.rightTray }}-{{ scope.row.rightTray2 }}
			</template>
		  </el-table-column>


		

		 
		  
		 
			


		  <el-table-column  label="错误码" width="75" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.error }}
			</template>
		  </el-table-column>





		  <!-- <el-table-column prop="take_Station1" label="取货站台" width="100" show-overflow-tooltip="" />	
		
		  <el-table-column prop="set_Station1" label="放货站台" width="100" show-overflow-tooltip="" />
				
		  <el-table-column  label="状态" width="100" show-overflow-tooltip="" >

<template #default="scope">
				<el-tag
				  :type="scope.row.state === 0 ? 'danger' : scope.row.state==2?'success':'info'"
				  disable-transitions >{{ scope.row.state === 2 ? '动作中' : scope.row.state===1?'等待中':'未联机' }}
				</el-tag>

				
</template>
</el-table-column> -->

<el-table-column  label="错误信息" show-overflow-tooltip="" >
	    
			      <template #default="scope" >
			   
					<el-tag v-if="scope.row.message" 
			          :type="scope.row.message ==''?'success':'danger'"
			          disable-transitions >{{ scope.row.message }}
					</el-tag>
			      </template>
			    </el-table-column>
				
				  
				<el-table-column label="操作" width="140" align="center" fixed="right" show-overflow-tooltip="" >
					<template #default="scope">
					
						<el-button icon="ele-Switch" size="small" text="" type="primary" @click="scControl(scope.row)" v-auth="'unitSc:control'"> 调度 </el-button>
					</template>
				</el-table-column>
			</el-table>
			
			<scControlDialog
			    ref="scControlDialogRef"
			    :title="scControlDialogTitle"
			    @reloadTable="handleQuery"
      />

	  <cvTagDialog :tagtype="'sc'" :tagnumber="tagNumber"
			    ref="cvTagDialogRef"
			    			    
      />
			
		</el-card>
	</div>
</template>

<script lang="ts" setup>
	import { ref } from "vue";
	import { ElMessageBox, ElMessage } from "element-plus";

	//import { formatDate } from '/@/utils/formatTime';

	import cvTagDialog from '/@/views/main/grpc/unitCv/component/cvTagDialog.vue'
	import { GetProcessData } from '/@/api/main/grpcServer';

	import scControlDialog from '/@/views/main/grpc/unitF29Sc/component/scControlDialog.vue'

		
		const loading = ref(false);
		const tableData = ref<any>([]);
		const queryParams = ref<any>(
		{	
			
		});
	
	const tableParams = ref({
	page: 1,
	pageSize: 10,
	total: 0,
	});
	const tagNumber = ref(0);
	// cv点位详情弹窗
	const cvTagDialogRef=ref();

	const scControlDialogRef = ref();
	

	const scControlDialogTitle = ref("");

	// 查询操作
	const handleQuery = async () => {
	loading.value = true;
	let para={
		nums:queryParams.value.num,
		providerType:7	
		};

		
	
	
	var res = await GetProcessData(para);
	tableData.value = res.data.result ?? [];
	tableParams.value.total = res.data.result?.length;
	loading.value = false;
};



const filterExist = (value: number, row: any) => {
  return row.isExistTray==value;
}



const scControl=async(row:any)=>{

scControlDialogTitle.value = '堆垛机调度';
let data={
	num:row.num,	
	unitNum:row.unitNum
	
	
	
}
scControlDialogRef.value.openDialog(data);
};



handleQuery();
</script>


